using UnityEngine;

using System;
using System.Collections;
using Mono.Data.Sqlite;
public class Tesr : MonoBehaviour
{
	
	NetWorkToServer netWork;
	
	void Awake ()
	{
		GameObject go = GameObject.Find ("NetworkLayer");
		netWork = go.GetComponent<NetWorkToServer> ();
		/*
		string dbPath = "/Resources/DataBase/asst.bin";
        string appDBPath = Application.dataPath + dbPath;
		
        DbAccess db = new DbAccess(@"Data Source=" + appDBPath);
        using (SqliteDataReader sqReader = db.ExecuteQuery("SELECT * FROM RoleInfo WHERE RoleID='1'"))
        {
            if (sqReader.Read())
			{
			 	int n = sqReader.GetOrdinal("Man");
				Debug.Log(sqReader.GetDataTypeName(n));
               string name = sqReader.GetString(n);
				Debug.Log(name);
            }
            sqReader.Close();
        }
		*/
		//MySocket.getInstance().addEventListener(1,listen);
	}
	
	void OnGUI(){
		
		if(GUI.Button(new Rect(100,0,150,50),"Click to connect")){
			netWork.ConnectEX ("192.168.1.105", 12900);
		}
		
		if(GUI.Button(new Rect(300,0,150,50),"Check")){
			ByteArrayEx byt = new ByteArrayEx ();
			byt.writeInt ((int)SystemMsgFlag.MESSAGE_CHECK);
			byt.writeByte ((byte)SystemMsgFlag.MESSAGE_CHECKCONTENT);
			MySocket.getInstance ().Async_Send (byt.byteArray);
			
			ByteArrayEx byt1 = new ByteArrayEx();
	        byt1.writeInt(2);
	        byt1.writeInt(1);
	        byt1.writeMultiByteEx("gf");
	        byt1.writeMultiByteEx("123");
	        MySocket.getInstance().Async_Send(byt1.byteArray);
		}
		
		if(GUI.Button(new Rect(500,0,150,50),"play")){
			//EffectManagement.GetInstance().PlayEffect(gameObject,"LevelUp");
		}
		//SceneObject sceneObj =  (SceneObject)ModelLocator.getInstance().scene.GetProperties("objID");
		//string name = (string)sceneObj.GetProperties("name");
		//int level = (int)sceneObj.GetProperties("level");
	}
	/*
	void listen(System.Object getter,DispatchEventArgs e){
		Debug.Log("has received");
		for(int i = 0;i < e.data.Length;i++){
			Debug.Log(e.data[i]);
		}
	}
	*/
}
